﻿using LaunchAllaround.DesignPattern.MVC;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace LaunchAllaround.Engine
{
    /// <summary>
    /// Logique d'interaction pour KinectStatusView.xaml
    /// </summary>
    public partial class KinectStatusView : UserControl, Controller<Kinect>, View<Kinect>
    {

        private Model<Kinect> model;
        
        public KinectStatusView(Model<Kinect> model)
        {
            InitializeComponent();
            this.model = model;

        }

        public void Refresh(RefreshEvent<Kinect> ev)
        {
            if (ev is RefreshKinectStatus)
            {
                switch (((RefreshKinectStatus)(ev)).Status)
                {
                    case Microsoft.Kinect.KinectStatus.Connected:
                        this.syncImg.Visibility = Visibility.Hidden;
                        this.failureImg.Visibility = Visibility.Hidden;
                        this.successImg.Visibility = Visibility.Visible;
                        break;
                    case Microsoft.Kinect.KinectStatus.Disconnected:
                        this.successImg.Visibility = Visibility.Hidden;
                        this.syncImg.Visibility = Visibility.Hidden;
                        this.failureImg.Visibility = Visibility.Visible;
                        break;
                    default:
                        this.successImg.Visibility = Visibility.Hidden;
                        this.failureImg.Visibility = Visibility.Hidden;
                        this.syncImg.Visibility = Visibility.Visible;
                        break;
                } 
            }
        }

        public Model<Kinect> GetModel()
        {
            return this.model;
        }

        public void SetModel(Model<Kinect> model)
        {
            this.model = model;
        }

    }
}
